/*
 * @Author: 闫一丹 1437921153@qq.com
 * @Date: 2023-01-05 15:09:56
 * @LastEditors: egg1bro
 * @LastEditTime: 2023-02-16 16:32:45
 * @FilePath: \team-design-backend\routes\note.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const express = require('express')
// 创建路由对象
const router = express.Router()
const note_controller = require('../controller/note')
// 导入验证数据合法性的中间件
const expressJoi = require('@escook/express-joi')
// 导入需要的验证规则对象
const { get_note_schema, add_note_schema, get_cate_schema } = require('../schema/note')
// 导入上传文件controller 
const uploadFile = require('../controller/uploadImg')

// 图片上传
let multer = require('multer');
// 文件暂存本地文件夹-自动生成./tmp/
let upload = multer({
    dest: './tmp/'
});

router.post('/upload', upload.single('file'), uploadFile.uploadFile)
router.get('/noteList/:id', expressJoi(get_note_schema), note_controller.getShareNoteList)
router.post('/addNote', expressJoi(add_note_schema), note_controller.writeNote)
router.get('/cates/:note_id', expressJoi(get_cate_schema), note_controller.getArticleById)

// 将路由对象共享出去
module.exports = router